﻿#pragma once
#include "Render/Matrix.h"
#include <memory>

enum class ImageType
{
	Unknown = 0,
	YUYV422 = 1,
	YUV422 = 2,
	YUV420 = 3,
	RGB = 4,
	RGBA = 5
};

struct VideoBuffer
{
	int width;
	int height;
	ImageType type;
	std::shared_ptr<unsigned char> buffer;
};

class Primitive;

class GlesContext
{
public:
	GlesContext();
	~GlesContext();

	/** 初始化渲染格式 */
	void setup(ImageType type);

	/** 绘制 */
	void draw(int width, int height);

	/** 更新图像 */
	void updateImage(void* buffer[], int width, int height);

	/** 是否有效 */
	bool isValid();

	Primitive* primitive()
	{
		return _primitive;
	}

	Matrix& matrix()
	{
		return _matrix;
	}

private:
	/** 渲染格式 */
	ImageType _type;

	/** 画布宽高 */
	int _width;
	int _height;

	/** 渲染器 */
	Primitive* _primitive;

	/** 变换矩阵 */
	Matrix _matrix;
};